﻿/******************************************************************************
 * Copyright (C) 2015  671643387@qq.com
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 *****************************************************************************/

#ifndef GAME_GAMEAPPLICATION_H_
#define GAME_GAMEAPPLICATION_H_

#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif

#include "Ucop/Typedefs.h"
#include "Ucop/Util/OptionSet.h"
#include "Ucop/Util/Application.h"
#include "Ucop/Net/TcpServer.h"
#include "Ucop/System/Event.h"
#include "Ucop/Data/Rel/Session.h"
using Ucop::String;
using Ucop::Util::OptionSet;
using Ucop::Net::TcpServer;
using Ucop::System::Event;
using Ucop::Data::Rel::Session;


class GameApplication : public Ucop::Util::Application
{
public:
	GameApplication(void);
	virtual ~GameApplication(void);

protected:
    virtual void OnDefineOptions(OptionSet& _Options);
    virtual int OnOption(const String& _Name, const String& _Arg);
    virtual int OnInitialize(void);
    virtual void OnSignal(int _Signal);
    virtual int Main(std::vector<String>& _UnknownArgs);
    virtual void OnUninitialize(void);

private:
    String _MyconfPath;
    TcpServer _MytcpServer;
    Event _MystopEvent;
    volatile bool _Myrunning;

	Session _MyloginDB;
	Session _MycharaDB;
	Session _MyworldDB;
	DISALLOW_COPY_AND_ASSIGN(GameApplication);
};

#endif // GAME_GAMEAPPLICATION_H_
